<template>
  <div>
    Next page
    {{ name }},,,{{ age }},,,{{ json }}
  </div>
</template>
<script>
import { defineComponent, onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";

export default defineComponent({
  setup() {
    let router = useRouter();
    // TODO route是当前路由，router是全局路由
    let route = useRoute()
    let name = ref("");
    let age = ref(0);
    let json = ref({});
    let r = ref(route);
    onMounted(() => {
      console.log(route);
      name.value = route.params.name;
      age.value = route.params.age * 1;
      json.value = JSON.stringify(route.params.json);
    });
    return {
      name,
      age,
      json,
    };
  },
});
</script>
